// (C) 2022 Intel Corporation. All rights reserved.
// Your use of Intel Corporation's design tools, logic functions and other 
// software and tools, and its AMPP partner logic functions, and any output 
// files from any of the foregoing (including device programming or simulation 
// files), and any associated documentation or information are expressly subject 
// to the terms and conditions of the Intel Program License Subscription 
// Agreement, Intel FPGA IP License Agreement, or other applicable 
// license agreement, including, without limitation, that your use is for the 
// sole purpose of programming logic devices manufactured by Intel and sold by 
// Intel or its authorized distributors.  Please refer to the applicable 
// agreement for further details.

module A_cse_ocs_dpa_aes10c_gf16_mul_masked 
    #(
	parameter POLY1 = 3,
        parameter OCS_AES_DPA_USE_CTECH = 1
     )
    (
	input logic [3:0] a,
	input logic [3:0] a_mask,
	input logic [3:0] b,
	input logic [3:0] b_mask,
	input logic [3:0] o_mask,
	output logic [3:0] o
    );

    wire [3:0] x1, x2, x3, x4;
    wire [3:0] p1, p2, p3;

    // Combinational logic to compute the masked terms
   
    A_cse_ocs_dpa_aes10c_gf16_mul #(.POLY1(POLY1)) masked_mul0
	(
	  .a (a),
	  .b (b),
	  .o (x1)
	);

    A_cse_ocs_dpa_aes10c_gf16_mul #(.POLY1(POLY1)) masked_mul1
	(
	  .a (a),
	  .b (b_mask),
	  .o (x2)
	);

    A_cse_ocs_dpa_aes10c_gf16_mul #(.POLY1(POLY1)) masked_mul2
	(
	  .a (a_mask),
	  .b (b),
	  .o (x3)
	);

    A_cse_ocs_dpa_aes10c_gf16_mul #(.POLY1(POLY1)) masked_mul3
        (
          .a (a_mask),
          .b (b_mask),
          .o (x4)
        );


    A_cse_ocs_dpa_aes10c_xor4_wrapper 
        #( .OCS_AES_DPA_USE_CTECH(OCS_AES_DPA_USE_CTECH) )
    i_cse_ocs_dpa_aes10c_xor4_wrapper 
        ( .x1(x1),
          .x2(x2),
          .x3(x3),
          .x4(x4),
          .o_mask(o_mask),
          .o(o));

endmodule
